// 时间戳转换时间格式   10位需要乘1000   
export const formatDate = function(value) {
	let date = new Date(value.toString().length == 10 ? parseInt(value) * 1000 : parseInt(value));
	let y = date.getFullYear();
	let MM = date.getMonth() + 1;
	MM = MM < 10 ? ('0' + MM) : MM;
	let d = date.getDate();
	d = d < 10 ? ('0' + d) : d;
	let h = date.getHours();
	h = h < 10 ? ('0' + h) : h;
	let m = date.getMinutes();
	m = m < 10 ? ('0' + m) : m;
	let s = date.getSeconds();
	s = s < 10 ? ('0' + s) : s;
	return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
};

// 截取当前数据到小数点后两位
export const numFilter = function(value) {
	let realVal = parseFloat(value).toFixed(2)
	return realVal
};

// 过滤空格回车
export const filterSpace = function(description) {
	description = description.replace(/(\n)/g, "");
	description = description.replace(/(\t)/g, "");
	description = description.replace(/(\r)/g, "");
	description = description.replace(/<\/?[^>]*>/g, "");
	return description;
}

// 手机号正则
export const regPhone = function checkPhone(phone){ 
    if(!(/^1[3456789]\d{9}$/.test(phone))){ 
        return false; 
    }
}
